package com.wwdeng.smart.video.adapter

import android.graphics.Color
import android.util.Log
import android.widget.LinearLayout
import androidx.recyclerview.widget.RecyclerView
import cn.bingoogolapple.androidcommon.adapter.BGARecyclerViewAdapter
import cn.bingoogolapple.androidcommon.adapter.BGAViewHolderHelper
import com.bumptech.glide.Glide
import com.wwdeng.smart.R
import org.json.JSONObject

/**
 * android
 * @Author：wwdeng
 * @CreateTime：2024/9/16 17:35
 * <pre>
 * 回放适配器
 * </pre>
 */
class VideoRecordAdapter(recyclerView: RecyclerView?) :
    BGARecyclerViewAdapter<JSONObject>(recyclerView, R.layout.item_video_recording) {
    override fun setItemChildListener(helper: BGAViewHolderHelper, viewType: Int) {
        helper.setItemChildClickListener(R.id.itemLayout) //点击Item
    }

    override fun fillData(helper: BGAViewHolderHelper, position: Int, model: JSONObject) {
        Log.e("TAG",">>>>url>>>>>>>"+model.optString("imgUrl"))
        val imgView = helper.getImageView(R.id.imgView)
        Glide.with(mContext).load(model.optString("imgUrl")).into(imgView)

        helper.setText(R.id.txtVTitle,model.optString("videoTitle"))
        helper.setText(R.id.txtVDuration,model.optString("videoDuration"))

        val itemLayout = helper.getView<LinearLayout>(R.id.itemLayout)
        if (model.optBoolean("isSelect",false)){
            itemLayout.setBackgroundColor(Color.parseColor("#F8FBFF"))
        } else {
            itemLayout.setBackgroundColor(Color.parseColor("#FFFFFF"))
        }
    }
}